<?php

$wpage = new WPage;

$wpage->vars('header', 'get_header');

$slugname = '';

?>

<?php if (is_author()) : ?>

	<?php $slugname = 'author'; ?>
	<?php if (have_posts()) : the_post(); ?>
		<h3>Author Archives: <span class="fancy"><?php the_author_meta('first_name'); ?> <?php the_author_meta('last_name'); ?> (<?php the_author_meta('display_name'); ?>)</span></h3>
		<?php if (get_the_author_meta( 'description' )) : ?>
			<table><tr><td class="top">
				<?php echo get_avatar(get_the_author_meta('user_email'), 60); ?>
			</td><td class="top">
				<?php the_author_meta('description'); ?>
			</td></tr></table><br />
		<?php endif; ?>
	<?php endif; rewind_posts(); ?>

<?php elseif (is_category()) : ?>

	<?php $slugname = 'category'; ?>
	<h3>Category Archives: <span class="fancy"><?php single_cat_title(); ?></span></h3>
	<?php $description = category_description(); ?>
	<?php if (!empty($description)) { ?><p><?php echo $description; ?></p><?php } ?>

<?php elseif (is_page()) : ?>

	<?php $slugname = 'page'; ?>

<?php elseif (is_search()) : ?>

	<?php $slugname = 'search'; ?>
	<h3>Search Results for: <span class="fancy"><?php the_search_query(); ?></span></h3>
	<?php if (!have_posts()) : ?>
		<p>Sorry, but nothing matched your search criteria. Please try again.</p>
		<?php get_search_form(); ?>
	<?php endif; ?>

<?php elseif (is_single()) : ?>

	<?php $slugname = 'single'; ?>

<?php elseif (is_tag()) : ?>

	<?php $slugname = 'tag'; ?>
	<h3>Tag Archives: <span class="fancy"><?php single_tag_title(); ?></span></h3>

<?php elseif (is_archive()) : // returns true if this is an 'author', 'category', 'date', or 'tag' based page ?>

	<?php $slugname = 'archive'; ?>
	<?php if (have_posts()) : the_post(); ?>
		<?php if (is_day()) : ?>
			<h3>Daily Archives: <span class="fancy"><?php the_date(); ?></span></h3>
		<?php elseif (is_month()) : ?>
			<h3>Monthly Archives: <span class="fancy"><?php the_date('F Y'); ?></span></h3>
		<?php elseif (is_year()) : ?>
			<h3>Yearly Archives: <span class="fancy"><?php the_date('Y'); ?></span></h3>
		<?php else : ?>
			<h3>Blog Archives</h3>
		<?php endif; ?>
	<?php endif; rewind_posts(); ?>

<?php endif; ?>

<?php

$wpage->vars('content', array('get_template_part', 'loop', $slugname));

$wpage->vars('sidebar', 'get_sidebar');

$wpage->vars('footer', 'get_footer');

display_page();

?>